import request from '@/utils/request'
import config from '@/config.js'

const prefix = "/wechat/auth"

// 授权手机号
export function auth(code) {
	const openId = uni.getStorageSync("user_auth_data")?.openid // 获取openid，假设你已经存储了它
    return request({
        url: `${prefix}/authPhone/${code}/${openId}`,
        method: 'post'
    })
}


// 静默登录
export function wechatLogin(data) {
    return request({
        url: `${prefix}/login`,
        method: 'post',
		data: {
			...data,
			appId: config.appInfo.appId, // 替换为你的小程序的appId
		}
    })
}


// 静默登录
export function wechatSetCource(data) {
    return request({
        url: `${prefix}/setSource`,
        method: 'put',
		data: data
    })
}
 
 
// 退出方法
export function logout() {
    return request({
        url: '/logout',
        method: 'post'
    })
}
